#ifndef __CLASS_FISH_CONTROL_H__
#define __CLASS_FISH_CONTROL_H__

#include <Arduino.h>
#include <Protothread.hpp>

class FishControl : public Protothread
{
public:
    enum TypeLight
    {
        OFF = 0,    //00
        BLUE = 1,   //01
        WHITE = 2,  //10
        ALL_ON = 3, //11
    };

private:
    uint32_t _pin_in;
    uint32_t _pin_pwm0;
    uint32_t _pin_pwm1;

    int32_t _st_lamp;
    int32_t _st_last_lamp;

    int16_t lightVal[4] = {0, 0, 0, 0};
    int32_t _push_touch;
    int8_t _plus_flags;
    boolean _need_update;
    
public:
    FishControl(uint32_t pin_in, uint32_t pin_pwm0, uint32_t pin_pwm1);
    ~FishControl();

    void init();
    virtual bool Run();
    void setLamp(uint8_t state, bool save = false);
    uint8_t getLamp();
    int32_t getBrightness();

    void setNextLamp(bool save = false);
    void switchOnLamp(bool on);
    void setBrightness(int32_t brightness);

    String getLampValue();

private:
    void procISR(void);
    void procLamp(bool notify_update = true);
};

extern FishControl fishCtrl;
#endif //!__CLASS_FISH_CONTROL_H__